<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>添加发票信息</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div class="fieldset1 tabel_col clearFix">
            <div class="fieldBox col_100">
                <div class="label">发票上传</div>
                <div class="field">
                    <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload4.jsp" flush="true">
                        <jsp:param name="filePath" value="capital/capPayInfo"/>
                    </jsp:include>
                    <input id="tabNm" name="tabNm" type="hidden" value="PRJ_PRD_INVOICE">
                    <input id="pkId" name="pkId" type="hidden" value="${vehInfo.id}">
                </div>
            </div>
        </div>
        <form id="prj_prd_veh_info_form">
            <div class="sqPanel">
                <div class="sqPanel_head inL">
                    <span>发票扫描照片信息</span>
                </div>
                <table class="table_full tbl_1">
                    <tbody id="imgTable">

                    </tbody>
                </table>
            </div>
            <div align="center"><span id="ocrBtn" onclick="ocrBtn()" class="sq-button sq-button-round">OCR识别</span>
            </div>
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_100">
                    <div class="label"><span class="requiredSymbol">*</span>发票类别</div>
                    <div class="field">
                        <span><input name="invoiceType" type="radio" onclick="dynamic('1')" <c:if test='${vehInfo.invoiceType==1 }'> checked </c:if> value="1">机动车销售统一发票（非挂车）</span>
                        <span><input name="invoiceType" type="radio" onclick="dynamic('2')" <c:if test='${vehInfo.invoiceType==2 }'> checked </c:if> value="2">机动车销售统一发票（挂车）</span>
                        <span><input name="invoiceType" type="radio" onclick="dynamic('3')" <c:if test='${vehInfo.invoiceType==3 }'> checked </c:if> value="3">二手车销售统一发票（非挂车）</span>
                        <span><input name="invoiceType" type="radio" onclick="dynamic('4')" <c:if test='${vehInfo.invoiceType==4 }'> checked </c:if> value="4">二手车销售统一发票（挂车）</span>
                        <span><input name="invoiceType" type="radio" onclick="dynamic('5')" <c:if test='${vehInfo.invoiceType==5 }'> checked </c:if> value="5">其他发票（专票）</span>
                        <span><input name="invoiceType" type="radio" onclick="dynamic('6')" <c:if test='${vehInfo.invoiceType==6 }'> checked </c:if> value="6">其他发票（普票）</span>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label"><span class="requiredSymbol">*</span>发票类型</div>
                    <div class="field">
                            <span><input name="flag" type="radio" onclick="checkInvoiceFlagRepeat(this)" <c:if test='${vehInfo.flag==10}'> checked </c:if> value="10">设备发票原件</span>
                            <span><input name="flag" type="radio" onclick="checkInvoiceFlagRepeat(this)" <c:if test='${vehInfo.flag==21}'> checked </c:if> value="21">汽车配件票1 </span>
                            <span><input name="flag" type="radio" onclick="checkInvoiceFlagRepeat(this)" <c:if test='${vehInfo.flag==22}'> checked </c:if> value="22">汽车配件票2 </span>
                            <span><input name="flag" type="radio" onclick="checkInvoiceFlagRepeat(this)" <c:if test='${vehInfo.flag==23}'> checked </c:if> value="23">汽车配件票3 </span>
                            <span><input name="flag" type="radio" onclick="checkInvoiceFlagRepeat(this)" <c:if test='${vehInfo.flag==24}'> checked </c:if> value="24">汽车配件票4 </span>
                            <span><input name="flag" type="radio" onclick="checkInvoiceFlagRepeat(this)" <c:if test='${vehInfo.flag==25}'> checked </c:if> value="25">汽车配件票5 </span>
                            <span><input name="flag" type="radio" onclick="checkInvoiceFlagRepeat(this)" <c:if test='${vehInfo.flag==26}'> checked </c:if> value="26">汽车配件票6 </span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <span>${cstNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">合同号</div>
                    <div class="field">
                        <span><a href="javascript:prjDetailBtn(${prjId});">${lsCntNo}</a></span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <span><a href="javascript:payDetailBtn(' ' ,${paySchId},${prjPrdId },${prjId});"></a>${paySchNo}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">租赁物名称</div>
                    <div class="field">
                        <span>${prdNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label"><span class="requiredSymbol">*</span>发票代码</div>
                    <div class="field">
                        <span><input name="invoicecode" id="invoicecode" type="text" class="ui-textbox"
                                     onblur="checkCode(this)" value="${vehInfo.invoicecode}" validate="{required:true}"></span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label"><span class="requiredSymbol">*</span>发票号码</div>
                    <div class="field">
                        <span><input name="invoicenum" id="invoicenum" type="text" class="ui-textbox"
                                     onblur="checkRepeat()" value="${vehInfo.invoicenum}"
                                     validate="{required:true}"></span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label"><span class="requiredSymbol">*</span>开票日期</div>
                    <div class="field">
                        <span><input id="invoicedate" type="text" class="ui-datepicker" value="${vehInfo.invoicedate}"
                                     validate="{required:true}"></span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label"><span class="requiredSymbol">*</span><span class="dynamic">发票校验码后6位</span></div>
                    <div class="field">
                        <span><input id="dynamicField" type="text" class="ui-textbox" validate="{required:true}"></span>
                    </div>
                </div>

            </div>
            <br/>
            <div align="center">点击按钮，获取发票其他信息:<span id="getBtn" onclick="dataPay();" class="sq-button sq-button-round">获取</span>
            </div>
            <div class="fieldset1 tabel_col clearFix">


                <div class="fieldBox col_50">
                    <div class="label">购方名称</div>
                    <div class="field">
                        <input name="purchaser" id="purchaser" type="text" class="ui-textbox"
                               value="${vehInfo.purchaser}" validate="{required:true}"></span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">购方税号</div>
                    <div class="field">
                        <input name="payercode" id="payercode" type="text" class="ui-textbox"
                               value="${vehInfo.payercode}" validate="{required:true}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">车辆类型</div>
                    <div class="field">
                        <input name="vehType" id="vehType" type="text" class="ui-textbox" value="${vehInfo.vehType}"
                               validate="{required:true}"></span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">厂牌型号</div>
                    <div class="field">
                        <input name="manumode" id="manumode" type="text" class="ui-textbox" value="${vehInfo.manumode }"
                               validate="{required:true}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">产地</div>
                    <div class="field">
                        <input name="producer" id="producer" type="text" class="ui-textbox" value="${vehInfo.producer }"
                               validate="{required:true}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">合格证号</div>
                    <div class="field">
                        <input name="certificateNo" id="certificateNo" type="text" class="ui-textbox"
                               value="${vehInfo.certificateNo }" validate="{required:true}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">进口证明书</div>
                    <div class="field">
                        <input name="importCert" id="importCert" type="text" class="ui-textbox"
                               value="${vehInfo.importCert}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">商检单号</div>
                    <div class="field">
                        <input name="inspectNo" id="inspectNo" type="text" class="ui-textbox"
                               value="${vehInfo.inspectNo}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">发动机号</div>
                    <div class="field">
                        <input name="enginenum" id="enginenum" type="text" class="ui-textbox"
                               value="${vehInfo.enginenum }">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">车驾号/VIN码</div>
                    <div class="field">
                        <input name="vinnum" id="vinnum" type="text" class="ui-textbox" value="${vehInfo.vinnum }">

                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">合计金额（税价合计）</div>
                    <div class="field">
                        <input name="pricetax" id="pricetax" type="text" class="ui-textbox" value="${vehInfo.pricetax}"
                               validate="{required:true}">
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">销方名称（销货单位名称）</div>
                    <div class="field">
                        <input name="saler" id="saler" type="text" class="ui-textbox" value="${vehInfo.saler }">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">销方电话</div>
                    <div class="field">
                        <input name="salesPhone" id="salesPhone" type="text" class="ui-textbox"
                               value="${vehInfo.salesPhone}">
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">销方税号</div>
                    <div class="field">
                        <input name="taxpayer" id="taxpayer" type="text" class="ui-textbox" value="${vehInfo.taxpayer}">
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">销方开户账号</div>
                    <div class="field">
                        <input name="salesAccount" id="salesAccount" type="text" class="ui-textbox"
                               value="${vehInfo.salesAccount}">
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">销方开户银行</div>
                    <div class="field">
                        <input name="salesBank" id="salesBank" type="text" class="ui-textbox"
                               value="${vehInfo.salesBank}">
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">销方地址</div>
                    <div class="field">
                        <input name="salesAddr" id="salesAddr" type="text" class="ui-textbox"
                               value="${vehInfo.salesAddr}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">销方地址/电话</div>
                    <div class="field">
                        <input name="salesAddrPhone" id="salesAddrPhone" type="text" class="ui-textbox"
                               value="${vehInfo.salesAddrPhone}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">税率(%)</div>
                    <div class="field">
                        <input name="taxrate" id="taxrate" type="text" class="ui-textbox" value="${vehInfo.taxrate}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">税额</div>
                    <div class="field">
                        <input name="tax" id="tax" type="text" class="ui-textbox" value="${vehInfo.tax}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">主管税务机关名称</div>
                    <div class="field">
                        <input name="taxOffice" id="taxOffice" type="text" class="ui-textbox"
                               value="${vehInfo.taxOffice}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">主管税务机关代码</div>
                    <div class="field">
                        <input name="taxOfficeCode" id="taxOfficeCode" type="text" class="ui-textbox"
                               value="${vehInfo.taxOfficeCode}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">不含税单价</div>
                    <div class="field">
                        <input name="noTax" id="noTax" type="text" class="ui-textbox" value="${vehInfo.noTax}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">完税凭证号码</div>
                    <div class="field">
                        <input name="payTaxCode" id="payTaxCode" type="text" class="ui-textbox"
                               value="${vehInfo.payTaxCode}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">吨位</div>
                    <div class="field">
                        <input name="tonnage" id="tonnage" type="text" class="ui-textbox" value="${vehInfo.tonnage}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">限乘人数</div>
                    <div class="field">
                        <input name="maxPassenger" id="maxPassenger" type="text" class="ui-textbox"
                               value="${vehInfo.maxPassenger}">
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">开票人</div>
                    <div class="field">
                        <input name="issued" id="axleLoad" type="text" class="ui-textbox" value="${vehInfo.issued}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">机器编号</div>
                    <div class="field">
                        <input name="machinecode" id="machinecode" type="text" class="ui-textbox"
                               value="${vehInfo.machinecode}">
                    </div>
                </div>
                <div class="fieldBox col_50" style="display: none">
                    <div class="field">
                        <input id="invoinceId" type="text" value="${vehInfo.id}">
                        <input id="dtlId" type="text" value="${dtlId}">
                        <input id="flag" type="text" value="${flag}">
                        <input name="prjId" type="text" value="${prjId}">
                        <input name="paySchId" type="text" value="${paySchId}">
                        <input id="paySchNo" name="paySchNo" type="text" value="${paySchNo}">
                        <input id="up_file_id" value="${vehInfo.fileId}">
                        <input id="up_absLocPath" value="${absLocPath}"/>
                        <input id="invoiceCount" value="${invoiceCount}"/>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="btnsBox">
        <%--<c:choose>
            <c:when test="${vehInfo.id!='' && vehInfo.id!=null }">
                <c:if test="${vehInfo.flag=='1' }">
                    <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round"
                          onclick="save();">修改主票</span>
                    <!-- <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round" onclick="updateMainAdd();">修改主票并继续添加补票</span> -->
                </c:if>
                <c:if test="${vehInfo.flag=='2' }">
                    <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round" onclick="updateBuPiao();">修改补票</span>
                </c:if>
            </c:when>
            <c:when test="${flag!='' && flag=='1'}">
                <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round"
                      onclick="addBuPiao();">新增补票</span>
            </c:when>
            <c:when test="${flag!='' && flag=='2'}">
                <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round"
                      onclick="addBuPiao();">新增补票</span>
            </c:when>
            <c:otherwise>
                <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round" onclick="save();">保存主票</span>
                <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round" onclick="saveAndAdd();">保存主票并继续添加补票</span>
            </c:otherwise>
        </c:choose>--%>
        <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round" onclick="save();">保存</span>
    </div>
</div>

<script type="text/javascript">
    // 当前记录id
    var id = '${id}';
    var detailFlag = '${detailFlag}';
    var dtlId = '${dtlId}';
    var imgPath = '${imgPath}';
    var buOrgCd = '${buOrgCd}';
    //项目类型
    var prjTypCd = "${prjTypCd}";
    //是否风控审批GPS节点，0-否，1-是
    var isGpsNode = "${isGpsNode}";
    //合格证审核状态
    var audStsCd = "${audStsCd}";
    var fileNm;
    var filePath = $('#up_absLocPath').val();
    var wait_dialog;
    //后台校验flag是否重复  1：不重复 2：重复
    var invoiceFlag;
    //后台校验发票号码是否重复  1：不重复 2：重复
    var invoiceNumFlag;
    //配置子编号
    var flag = "${flag}";

    $(function () {
        var ligerForm = liger.get("prj_prd_veh_info_form");
        $("#prj_prd_veh_info_form").ligerForm({
            validate: true
        });
        if (buOrgCd == "00000013") {
            $("span[isValid='newEngery']").each(function () {
                $("input[isValid='newEngery']").each(function () {
                    $(this).attr("validate", "");
                });
                $(this).hide();
            });
        }
        if (isGpsNode == '1') { //风控审批GPS
            // setReadOnly();
        }
        if (StringUtils.isNotEmpty($('#invoinceId').val())) {
            $('input:radio[name="flag"]').attr("disabled",true);
        }
        //setFormatDateValue();
        if (StringUtils.isNotEmpty($('#up_file_id').val())) {
            prjPrdVehImgList();
        }
        //根据发票类别初始化动态数据
        initDynamic();
        // dynamic(flag);
        //scanData();
    });

    function uploadCallbackForMore(fileData) {
        var sysCd = "${sysCd}";
        var orgCd = "${orgCd}";
        var cfgCd = "${cfgCd}";
        var cfgDtlCd = "${cfgDtlCd}";
        var old_file_id = $('#up_file_id').val();
        var fileList = new Array();
        var params = {};
        for (var i = 0; i < fileData.length; i++) {
            var obj = {};
            obj.fileNm = fileData[i].fileNm;
            obj.filePath = fileData[i].filePath;
            obj.pkId = dtlId;
            obj.sysCd = sysCd;
            obj.orgCd = orgCd;
            obj.cfgCd = cfgCd;
            obj.cfgDtlCd = cfgDtlCd;
            fileList.push(obj);
        }
        params.sysCd = sysCd;
        params.orgCd = orgCd;
        params.cfgCd = cfgCd;
        params.cfgDtlCd = cfgDtlCd;
        params.old_file_id = old_file_id;
        params["fileList"] = JSON.stringify(fileList);
        var url = '<%=path%>/project/prjPrdInvoice/addProjectInvoicePhoto.do';
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: params,
            url: url,
            success: function (msg) {
                //alert();
                //alert( $('#up_file_id').val());
                if (msg) {
                    $('#up_file_id').val(msg.data.id);
                    $('#up_absLocPath').val(msg.data.absLocPath);
                    // ocrBtn();
                    prjPrdVehImgList();

                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    function uploadCallback(fileData) {
        fileNm = fileData[0].fileNm;
        filePath = fileData[0].filePath;
        fileData[0].filePath = serverPrefixPath + fileData[0].filePath;
        initImgData(fileData);
    }

    //保存发票资料
    function addProjectInvoicePhoto() {
        var sysCd = "${sysCd}";
        var orgCd = "${orgCd}";
        var cfgCd = "${cfgCd}";
        var cfgDtlCd = flag;
        var old_file_id = $('#up_file_id').val();
        var fileList = new Array();
        var params = {};
        var obj = {};
        obj.fileNm = fileNm;
        obj.filePath = filePath;
        obj.pkId = $("#invoinceId").val();
        obj.sysCd = sysCd;
        obj.orgCd = orgCd;
        obj.cfgCd = cfgCd;
        obj.cfgDtlCd = cfgDtlCd;
        fileList.push(obj);
        params.sysCd = sysCd;
        params.orgCd = orgCd;
        params.cfgCd = cfgCd;
        params.cfgDtlCd = cfgDtlCd;
        params.old_file_id = old_file_id;
        params["fileList"] = JSON.stringify(fileList);
        var url = '<%=path%>/project/prjPrdInvoice/addProjectInvoicePhoto.do';
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: params,
            url: url,
            // async:false,
            success: function (msg) {
                if (msg.success == 1) {
                    $('#up_file_id').val(msg.data.id);
                    updateInvoiceFileId();
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    function prjDetailBtn(id) {
        var fromPrjFlag = true;
        var detailFlag = true;
        var _flag = $("#fromPrjFlagId").val();
        if (StringUtils.isNotEmpty(_flag)) {
            if (_flag == 'false') {
                fromPrjFlag = false;
            }
        }
        Add_navTab('tab_project_detail' + id, '项目详情', '<%=path%>/project/prjbscinfo/toModifyPage.do?fromPrjFlag=' + fromPrjFlag + '&&id=' + id + '&&detailFlag=' + detailFlag);
    }

    function prjPrdVehImgList() {
        var dtlId = '${dtlId}';
        var params = {};
        var fileId = $('#up_file_id').val();
        //params.fileId = fileId;
        var url = '<%=path%>/project/prjPrdInvoice/getPrjPrdInvoiceImg.do?';
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {'fileId': fileId},
            url: url,
            success: function (msg) {
                if (msg.success == 1) {
                    if (msg.data && msg.data.length > 0) {
                        initImgData(msg.data);
                    }
                }
            }
        });
    }

    function initImgData(data) {
        if (data && data.length > 0) {
            var html = "";
            html += "<tr>";
            for (var i = 0; i < data.length; i++) {
                var file = data[i];
                $('#up_absLocPath').val(file.absLocPath);
                if ((i + 1) % 4 == 0) {
                    html += "</tr>";
                    html += "<tr>";
                }
                html += "<td>";
                html += "<div class='imgBox'>";
                html += "<img id='imgPath'  src='"+ file.filePath + "' onclick='scanData(this,event);'  href='" + file.filePath + "'>";
                html += "</div>";
                html += "</td>";
            }
            html += "</tr>";
            $("#imgTable").html(html);
        }
    }

    function payDetailBtn(prjPrdDtlId, id, prjPrdId, prjId) {
        if (null == id) {
            id = "";
        }
        if (null == prjPrdDtlId) {
            prjPrdDtlId = "";
        }
        if (null == prjPrdId) {
            prjPrdId = "";
        }
        var editFlag = true;
        Add_navTab('tab_prj_quat_prps' + id, '查看支付表', '<%=path%>/project/prjprdpayschm/toAddPage.do?prjId=' + prjId + '&&id=' + id + '&&prjPrdDtlId=' + prjPrdDtlId + '&&prjPrdId=' + prjPrdId + '&&detailFlag=' + editFlag);
    }

    //保存发票信息
    function save() {
        var ligerForm = liger.get("prj_prd_veh_info_form");
        var invoicedate = $('#invoicedate').val();
        var invoicecode = $('#invoicecode').val();
        var invoicenum = $('#invoicenum').val();
        var invoiceType = $('input:radio[name="invoiceType"]:checked').val();
        flag = $('input:radio[name="flag"]:checked').val();

        if (StringUtils.isEmpty(invoicecode)) {
            top.$.ligerDialog.SQalert({content: '发票代码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (StringUtils.isEmpty(invoicenum) && StringUtils.isEmpty(invoiceNumFlag)) {
            top.$.ligerDialog.SQalert({content: '发票号码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (StringUtils.isEmpty(invoicecode) || invoicedate.length != 10) {
            top.$.ligerDialog.SQalert({content: '开票日期为空,或格式错误!', SQ_type: "warning"});
            return false;
        }
        if (StringUtils.isEmpty(invoiceType)) {
            top.$.ligerDialog.SQalert({content: '发票类别不能为空!', SQ_type: "warning"});
            return false;
        }
        if (StringUtils.isEmpty(flag)) {
            top.$.ligerDialog.SQalert({content: '发票类型不能为空!', SQ_type: "warning"});
            return false;
        }
        if ('2' == invoiceFlag) {
            top.$.ligerDialog.SQalert({content: '发票类型重复!', SQ_type: "warning"});
            return false;
        }
        checkRepeat();
        if ('2' == invoiceNumFlag) {
            top.$.ligerDialog.SQalert({content: '发票信息已存在!', SQ_type: "warning"});
            return false;
        }

        var data = ligerForm.getData();

        //上传发票文件照片id
        var fileId  = $('#up_file_id').val();
        data["fileId"] = fileId;
        var invoiceFilePath = $('#up_absLocPath').val();
        data["invoiceFilePath"] = invoiceFilePath;
        if (StringUtils.isEmpty(invoiceFilePath)) {
            top.$.ligerDialog.SQalert({content: '请先上传发票!', SQ_type: "warning"});
            return false;
        }
        var url = '<%=path%>/project/prjPrdInvoice/add.do?';
        //发票信息主键ID
        var id = $("#invoinceId").val();
        if (StringUtils.isNotEmpty(id)) {
            url = '<%=path%>/project/prjPrdInvoice/modify.do?';
        }
        var prjPrdChangeFlag = '${prjPrdChangeFlag}';
        data["prjPrdChangeFlag"] = prjPrdChangeFlag;
        //换车-调用新接口
        if (prjPrdChangeFlag && prjPrdChangeFlag == 'true') {
            if (StringUtils.isNotEmpty(id)) {
                url = '<%=path%>/project/prjPrdInvoice/modifyByHC.do?';
            } else {
                url = '<%=path%>/project/prjPrdInvoice/addByHC.do?';
            }
        }
        data["id"] = id;
        data["dtlId"] = dtlId;
        // 是否风控审批GPS节点，0-否，1-是
        data["isGpsNode"] = isGpsNode;
        data["invoicedate"] = invoicedate;
        var dynamicField = $('#dynamicField').val();
        if (undefined == dynamicField || '' == dynamicField || null == dynamicField || dynamicField <= 0.0) {
            top.$.ligerDialog.SQalert({content: $('.dynamic').html() + '不正确，请重新填写!', SQ_type: "warning"});
            return false;
        }
        if (invoiceType == '1' || invoiceType == '2' || invoiceType == '5') {
            data["untax"] = dynamicField;
        } else if (invoiceType == '3' || invoiceType == '4') {
            data["invoiceTotal"] = dynamicField;
        } else if (invoiceType == '6') {
            data["checkCode"] = dynamicField;
        }

        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    $("#invoinceId").val(msg.data);
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
                if (filePath != invoiceFilePath) {
                    //保存发票资料
                    addProjectInvoicePhoto();
                }else {
                    //关闭当前页面
                    Remove_navTab();
                }
            }
        });
    }

    function uploadFile(imgObj, sysCd, orgCd, cfgCd, cfgDtlCd) {
        var obj = $(imgObj).parent().parent().find("img")
        var dtlId = '${dtlId}';
        var url = '<%=path%>/project/prjprdvehinfo/addPrjPrdImgPage.do?sysCd=' + sysCd + '&&orgCd=' + orgCd + '&&cfgCd=' + cfgCd + '&&cfgDtlCd=' + cfgDtlCd + '&&dtlId=' + dtlId;
        $.ligerDialog.open({
            height: 300,
            width: 600,
            title: '上传图片',
            url: url,
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
            data: {
                imgObj: obj
            },
        });


    }

    //发票类别变化动态改变
    function dynamic(flag) {
        if (flag == '1' || flag == '2' || flag == '5') {
            $('.dynamic').html("发票未税金额(格式(1.00))");
        } else if (flag == '3' || flag == '4') {
            $('.dynamic').html("发票车价合计");
        } else if (flag == '6') {
            $('.dynamic').html("发票校验码后6位");
        }
    }

    //根据发票类别初始化数据
    function initDynamic() {
        var invoiceType = '${vehInfo.invoiceType}';
        if (invoiceType == '1' || invoiceType == '2' || invoiceType == '5') {
            $('.dynamic').html("发票未税金额(格式(1.00))");
            $('#dynamicField').val('${vehInfo.untax}');
        } else if (invoiceType == '3' || invoiceType == '4') {
            $('.dynamic').html("发票车价合计");
            $('#dynamicField').val('${vehInfo.invoiceTotal}');
        } else if (invoiceType == '6') {
            $('.dynamic').html("发票校验码后6位");
            $('#dynamicField').val('${vehInfo.checkCode}');
        }
    }

    //发票代码格式 小于12位，且为数字
    function checkCode(ele) {
        var reg = /^\d{10,12}$/;
        if (!reg.test($(ele).val())) {
            top.$.ligerDialog.SQalert({content: '请正确填写发票代码，必须为10～12位数字!', SQ_type: "warning"});
            // alert("请正确填写发票代码，必须为10～12位数字!")
            $(ele).val("");
            return false;
        }
    }

    //发票号码
    function checkRepeat() {
        var reg = /^\d{8}$/;
        var invoicenum = $('#invoicenum').val();
        if (!reg.test($('#invoicenum').val())) {
            top.$.ligerDialog.SQalert({content: '请正确填写发票号码，必须为8位数字!', SQ_type: "warning"});
            // alert("请正确填写发票号码，必须为8位数字!")
            $('#invoicenum').val("");
            return false;
        }
        var invoinceId = $('#invoinceId').val();
        var invoicecode = $('#invoicecode').val();
        var lsCntNo = '${lsCntNo}';
        var flag=$("input[name='flag']:checked").val();
        var prjId = '${prjId}';
        if (StringUtils.isEmpty(invoicecode) || StringUtils.isEmpty(flag)){
            top.$.ligerDialog.SQalert({content: '请先填写发票类型和发票代码!', SQ_type: "success"});
            $('#invoicenum').val("");
            return false;
        }
        //后台校验是否重复
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {"invoicenum": invoicenum,
                'id': invoinceId,
                'invoicecode' : invoicecode,
                'lsCntNo' : lsCntNo,
                'flag' : flag,
                'prjId' : prjId},
            url: "<%=path%>/project/prjPrdInvoice/checkInvoiceNumRepeat.do?",
            async:false,
            success: function (msg) {
                //wait_dialog.close();String result="1";//1校验不重复 2校验重复
                if (msg) {
                    if (msg == '2') {
                        top.$.ligerDialog.SQalert({content: '发票信息已存在!', SQ_type: "warning"});
                        $('#invoicenum').val("");
                    }
                    invoiceNumFlag = msg;
                } else {
                    top.$.ligerDialog.SQalert({content: "系统错误", SQ_type: "error"});
                }
            }
        });
    }

    //发票类别校验
    function checkInvoiceFlagRepeat(ele) {
        var paySchNo = $('#paySchNo').val();
        var flag = $(ele).val();
        var dtlId = '${dtlId}';
        var prjPrdChangeFlag = '${prjPrdChangeFlag}';
        //后台校验是否重复
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {"paySchNo": paySchNo, 'flag': flag,
                'prjPrdChangeFlag': prjPrdChangeFlag,
                'dtlId': dtlId
            },
            url: "<%=path%>/project/prjPrdInvoice/checkInvoiceFlagRepeat.do?",
            async:false,
            success: function (msg) {
                // 1校验不重复 2校验重复
                if (msg == '2') {
                    top.$.ligerDialog.SQalert({content: '发票类别重复!', SQ_type: "warning"});
                }
                invoiceFlag = msg;
            }
        });
    }

    //新增补票
    function addBuPiao() {

        var ligerForm = liger.get("prj_prd_veh_info_form");
        /* if (!ligerForm.valid()) {
              wait_dialog.close();
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码typeof GPSstr != "undefined" && null != GPSstr && "" != GPSstr
        } */
        var invoicedate = $('#invoicedate').val();
        var invoicecode = $('#invoicecode').val();
        var invoicenum = $('#invoicenum').val();
        if (invoicecode == '' || invoicecode == null) {
            top.$.ligerDialog.SQalert({content: '发票代码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (invoicenum == '' || invoicenum == null) {
            top.$.ligerDialog.SQalert({content: '发票号码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (invoicedate == '' || invoicedate == null) {
            top.$.ligerDialog.SQalert({content: '开票日期不能为空!', SQ_type: "warning"});
            return false;
        }

        var data = ligerForm.getData();

        var url = '<%=path%>/project/prjPrdInvoice/add.do?';
        var id = $("#invoinceId").val();//发票信息主键ID
        data["id"] = $("#invoinceId").val();
        data["dtlId"] = dtlId;
        data["isGpsNode"] = isGpsNode;// 是否风控审批GPS节点，0-否，1-是
        data["invoicedate"] = invoicedate;
        //invoiceType
        var invoiceType = $('input:radio[name="invoiceType"]:checked').val();
        var dynamicField = $('#dynamicField').val();
        if (invoiceType == '1' || invoiceType == '2' || invoiceType == '5') {
            data["untax"] = dynamicField;
        } else if (invoiceType == '3' || invoiceType == '4') {
            data["invoiceTotal"] = dynamicField;
        } else if (invoiceType == '6') {
            data["checkCode"] = dynamicField;
        }
        //flag 补票
        data["flag"] = 2;
        //上传发票文件照片id
        data["fileId"] = $('#up_file_id').val();

        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                Remove_navTab();//关闭当前页面
                if (msg.success == 1) {
                    $("#id").val(msg.data);
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});


                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //修改补票
    function updateBuPiao() {

        var ligerForm = liger.get("prj_prd_veh_info_form");
        /* if (!ligerForm.valid()) {
             wait_dialog.close();
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码typeof GPSstr != "undefined" && null != GPSstr && "" != GPSstr
        } */
        var invoicedate = $('#invoicedate').val();
        var invoicecode = $('#invoicecode').val();
        var invoicenum = $('#invoicenum').val();
        if (invoicecode == '' || invoicecode == null) {
            top.$.ligerDialog.SQalert({content: '发票代码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (invoicenum == '' || invoicenum == null) {
            top.$.ligerDialog.SQalert({content: '发票号码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (invoicedate == '' || invoicedate == null) {
            top.$.ligerDialog.SQalert({content: '开票日期不能为空!', SQ_type: "warning"});
            return false;
        }

        var data = ligerForm.getData();

        var url = '<%=path%>/project/prjPrdInvoice/modify.do?';
        var id = $("#invoinceId").val();//发票信息主键ID
        data["id"] = $("#invoinceId").val();
        data["dtlId"] = dtlId;
        data["isGpsNode"] = isGpsNode;// 是否风控审批GPS节点，0-否，1-是
        data["invoicedate"] = invoicedate;
        //invoiceType
        var invoiceType = $('input:radio[name="invoiceType"]:checked').val();
        var dynamicField = $('#dynamicField').val();
        if (invoiceType == '1' || invoiceType == '2' || invoiceType == '5') {
            data["untax"] = dynamicField;
        } else if (invoiceType == '3' || invoiceType == '4') {
            data["invoiceTotal"] = dynamicField;
        } else if (invoiceType == '6') {
            data["checkCode"] = dynamicField;
        }
        //flag 补票
        data["flag"] = 2;
        //上传发票文件照片id
        data["fileId"] = $('#up_file_id').val();

        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                Remove_navTab();//关闭当前页面
                if (msg.success == 1) {
                    $("#id").val(msg.data);
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});

                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //保存成功后修改发票上传文件id
    function updateInvoiceFileId() {
        var dataParams = {};
        var url = '<%=path%>/project/prjPrdInvoice/modify.do?';
        //发票信息主键ID
        dataParams.id =   $("#invoinceId").val();
        //上传发票文件照片id
        dataParams.fileId = $('#up_file_id').val();

        $.ajax({
            type: 'post',
            dataType: 'json',
            data: dataParams,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
                Remove_navTab();
            }
        });
    }

    //保存主票信息并继续添加补票
    function saveAndAdd() {

        var ligerForm = liger.get("prj_prd_veh_info_form");
        /* if (!ligerForm.valid()) {
              wait_dialog.close();
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码typeof GPSstr != "undefined" && null != GPSstr && "" != GPSstr
        } */
        var invoicedate = $('#invoicedate').val();
        var invoicecode = $('#invoicecode').val();
        var invoicenum = $('#invoicenum').val();
        if (invoicecode == '' || invoicecode == null) {
            top.$.ligerDialog.SQalert({content: '发票代码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (invoicenum == '' || invoicenum == null) {
            top.$.ligerDialog.SQalert({content: '发票号码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (invoicedate == '' || invoicedate == null) {
            top.$.ligerDialog.SQalert({content: '开票日期不能为空!', SQ_type: "warning"});
            return false;
        }

        var data = ligerForm.getData();

        var url = '<%=path%>/project/prjPrdInvoice/add.do?';
        var id = $("#invoinceId").val();//发票信息主键ID
        if (id != null && id != '') {
            url = '<%=path%>/project/prjPrdInvoice/modify.do?';
        }
        data["id"] = $("#invoinceId").val();
        data["dtlId"] = dtlId;
        data["isGpsNode"] = isGpsNode;// 是否风控审批GPS节点，0-否，1-是
        //flag
        data["flag"] = 1; //主票
        data["invoicedate"] = invoicedate;
        //invoiceType
        var invoiceType = $('input:radio[name="invoiceType"]:checked').val();
        var dynamicField = $('#dynamicField').val();
        if (invoiceType == '1' || invoiceType == '2' || invoiceType == '5') {
            data["untax"] = dynamicField;
        } else if (invoiceType == '3' || invoiceType == '4') {
            data["invoiceTotal"] = dynamicField;
        } else if (invoiceType == '6') {
            data["checkCode"] = dynamicField;
        }
        //上传发票文件照片id
        data["fileId"] = $('#up_file_id').val();

        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                Remove_navTab();//关闭当前页面
                if (msg.success == 1) {
                    $("#id").val(msg.data);
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    var detailFlag = false;
                    var timestamp = new Date().getTime();
                    var dtlId = '${dtlId}';
                    var prjId = '${prjId}';
                    var paySchId = '${paySchId}';
                    var paySchNo = '${paySchNo}';
                    var cstNm = '${cstNm}';
                    var lsCntNo = '${lsCntNo}';
                    var prdNm = '${prdNm}';
                    var flag = 2;
                    var url = '<%=path%>/project/prjPrdInvoice/toAddPage.do?detailFlag=' + detailFlag + '&&dtlId=' + dtlId + '&&prjId=' + prjId + '&&paySchId=' + paySchId + '&&paySchNo=' + paySchNo + '&&cstNm=' + cstNm + '&&prdNm=' + prdNm + '&lsCntNo=' + lsCntNo + '&flag=' + flag

                    Add_navTab('tab_prj_prd_invoince_info_add' + timestamp, '添加补票信息', url);

                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    var path;
    var num = 0;
    //发票信息ocr识别
    function ocrBtn() {
        var filePath = $('#up_absLocPath').val();
        //invoiceType
        var invoiceType = $('input:radio[name="invoiceType"]:checked').val();
        if (StringUtils.isEmpty(filePath)) {
            $.ligerDialog.SQalert({content: '请先上传一张发票!', SQ_type: "warring"});
            return;
        }
        if (StringUtils.isEmpty(invoiceType)) {
            $.ligerDialog.SQalert({content: '请先选择一种发票类别!', SQ_type: "warring"});
            return;
        }
        if (num >= 1 && path == filePath) {
            $.ligerDialog.SQalert({content: '同一张照片只能进行一次OCR识别!', SQ_type: "warring"});
            return;
        }

        var params = {};
        params.filePath = filePath;
        if ('1' == invoiceType || '2' == invoiceType) {
            params.type = 'invoice';
        }
        //二手车发票OCR识别，与OCR新接口同步上线
        /*else if ('3' == invoiceType || '4' == invoiceType) {
            params.type = 'invoiceUsedCar';
        }*/
        else{
            $.ligerDialog.SQalert({content: '当前发票类别不支持进行OCR识别!', SQ_type: "warring"});
            return;
        }

        $.ajax({
            type: 'post',
            dataType: 'json',
            data: params,
            url: '<%=path%>/project/prjPrdInvoice/getPrjPrdInvoiceOcr.do?',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    if (msg.data.success) {
                        top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
                        initDataOcr(msg.data);
                    } else {
                        if (null == msg.data.errmsg || '' == msg.data.errmsg) {
                            msg.data.errmsg = '获取异常，请稍候重试!';
                        }
                        top.$.ligerDialog.SQalert({content: "识别失败", SQ_type: "error"});
                    }
                } else {
                    top.$.ligerDialog.SQalert({content: "识别失败", SQ_type: "error"});
                }
            }
        });
        path = filePath;
        num += 1;
    }

    //ocr获取数据
    function initDataOcr(data) {
        if (data.prjPrdInvoiceDTO == null) {
            top.$.ligerDialog.SQalert({content: '发票获取失败!', SQ_type: "warning"});
            return false;
        }
        $('#invoicedate').val(data.prjPrdInvoiceDTO.invoicedate);
        $('#invoicecode').val(data.prjPrdInvoiceDTO.invoicecode);
        $('#invoicenum').val(data.prjPrdInvoiceDTO.invoicenum);
    }

    //  数据宝接口调用
    function dataPay() {
        //传递参数
        var invCode = $('#invoicecode').val();//发票代码
        var invNo = $('#invoicenum').val();//发票号码
        var invTime = $('#invoicedate').val();//开票日期，格式：20190416
        //格式化时间
        invTime = invTime.replace('-', '').replace('-', '');
        var invOther;//不含税金额(发票类型为专票时，填写未税金额；发票类型为二手车时，填写发票车价合计),格式： 60300.00
        var checkCode;//校验码(校验码后六位（发票类型为普票、电子票时不可为空）)

        if (invCode == '' || invCode == null) {
            top.$.ligerDialog.SQalert({content: '发票代码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (invNo == '' || invNo == null) {
            top.$.ligerDialog.SQalert({content: '发票号码不能为空!', SQ_type: "warning"});
            return false;
        }
        if (invTime == '' || invTime == null) {
            top.$.ligerDialog.SQalert({content: '开票日期不能为空!', SQ_type: "warning"});
            return false;
        }


        //invoiceType
        var invoiceType = $('input:radio[name="invoiceType"]:checked').val();
        if (invoiceType == '' || invoiceType == null || invoiceType == 'undefined') {
            top.$.ligerDialog.SQalert({content: '发票类别不能为空!', SQ_type: "warning"});
            return false;
        }

        var dynamicField = $('#dynamicField').val();
        if (invoiceType == '1' || invoiceType == '2' || invoiceType == '5') {
            invOther = $('#dynamicField').val();
            if (String(invOther).indexOf(".") > -1) {
            } else {
                top.$.ligerDialog.SQalert({content: '发票未税金额要保留2位小数!!', SQ_type: "warning"});
                return false;
            }
        } else if (invoiceType == '3' || invoiceType == '4') {
            invOther = $('#dynamicField').val();
            if (String(invOther).indexOf(".") > -1) {
            } else {
                top.$.ligerDialog.SQalert({content: '发票车价合计要保留2位小数!', SQ_type: "warning"});
                return false;
            }
        } else if (invoiceType == '6') {
            checkCode = $('#dynamicField').val();
        }


        var param = {
            'invCode': invCode,
            'invNo': invNo,
            'invTime': invTime,
            'invOther': invOther,
            'checkCode': checkCode
        };

        $.ajax({
            type: 'post',
            dataType: 'json',
            data: param,
            url: '<%=path%>/project/prjPrdInvoice/getPrjPrdInvoiceDataPay.do?',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();

                if (msg.success == 1) {
                    if (msg.data.success) {
                        initDataPay(msg.data);
                    } else {
                        if (msg.data.errmsg == '' || null == msg.data.errmsg) {
                            msg.data.errmsg = '获取异常，请稍候重试!';
                        }
                        top.$.ligerDialog.SQalert({content: "识别失败", SQ_type: "error"});
                    }
                } else {
                    top.$.ligerDialog.SQalert({content: "识别失败", SQ_type: "error"});
                }
            }
        });
    }//end  数据宝接口调用
    //数据宝接口返回数据初始化
    function initDataPay(data) {
        if (data.prjPrdInvoiceDTO == null) {
            top.$.ligerDialog.SQalert({content: '发票获取失败!', SQ_type: "warning"});
            return false;
        }
        $('#purchaser').val(data.prjPrdInvoiceDTO.purchaser);//购方名称
        $('#payercode').val(data.prjPrdInvoiceDTO.payercode);//购方税号
        $('#vehType').val(data.prjPrdInvoiceDTO.vehType);//车辆类型
        $('#manumode').val(data.prjPrdInvoiceDTO.manumode);//厂牌型号
        $('#producer').val(data.prjPrdInvoiceDTO.producer);//产地
        $('#certificateNo').val(data.prjPrdInvoiceDTO.certificateNo);//合格证号
        $('#importCert').val(data.prjPrdInvoiceDTO.importCert);//进口证明书
        $('#inspectNo').val(data.prjPrdInvoiceDTO.inspectNo);//商检单号
        $('#enginenum').val(data.prjPrdInvoiceDTO.enginenum);//发动机号
        $('#vinnum').val(data.prjPrdInvoiceDTO.vinnum);//车驾号/VIN码
        $('#pricetax').val(data.prjPrdInvoiceDTO.pricetax);//合计金额（税价合计）
        $('#saler').val(data.prjPrdInvoiceDTO.saler);//销方名称（销货单位名称）
        $('#salesPhone').val(data.prjPrdInvoiceDTO.salesPhone);//销方电话
        $('#taxpayer').val(data.prjPrdInvoiceDTO.taxpayer);//销方税号
        $('#salesAccount').val(data.prjPrdInvoiceDTO.salesAccount);//销方开户账号
        $('#salesBank').val(data.prjPrdInvoiceDTO.salesBank);//销方开户银行
        $('#salesAddr').val(data.prjPrdInvoiceDTO.salesAddr);//销方地址
        $('#salesAddrPhone').val(data.prjPrdInvoiceDTO.salesAddrPhone);//销方地址/电话
        $('#taxrate').val(data.prjPrdInvoiceDTO.taxrate);//税率
        $('#tax').val(data.prjPrdInvoiceDTO.tax);//税额
        $('#taxOffice').val(data.prjPrdInvoiceDTO.taxOffice);//主管税务机关名称
        $('#taxOfficeCode').val(data.prjPrdInvoiceDTO.taxOfficeCode);//主管税务机关代码
        $('#noTax').val(data.prjPrdInvoiceDTO.noTax);//不含税单价
        $('#payTaxCode').val(data.prjPrdInvoiceDTO.payTaxCode);//完税凭证号码
        $('#tonnage').val(data.prjPrdInvoiceDTO.tonnage);//吨位
        $('#maxPassenger').val(data.prjPrdInvoiceDTO.maxPassenger);//限乘人数
        $('#issued').val(data.prjPrdInvoiceDTO.issued);//开票人
        $('#machinecode').val(data.prjPrdInvoiceDTO.machinecode);//机器编号
    }//end 数据宝接口返回数据初始化

    function scanData(img, event) {
        event.preventDefault();
        var href = $(img).attr('src');
        // var href = "http://10.10.36.18/attachments/CCI20170301_0004.JPG";
        if (SQ.regs.img.test(href)) {
            SQ.imgPreview(href);
            /* var scan = SQ.scanCode({
                href: href,
                onScan: function (value) {
                    scan.close();
                }
            }); */
        } else {
            alert('不是图片');
        }
        ;
    }


</script>
</body>
</html>
